<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>堆快照监控内存</title>
</head>
<body>
    <button id="btn">Add</button>

    <script>
        var tmpEle  
        function test (){
            var ul = document.createElement('ul')
            for(var i = 0 ; i < 10; i++){
                var li = document.createElement('li')
                ul.appendChild(li)
            }
            tmpEle = ul // tmpEle此时是分离dom,会产生垃圾
            tmpEle = null // 将分离dom置为null后，其垃圾可以被回收
        }
        document.getElementById('btn').addEventListener('click', test)
    </script>
</body>
</html>